Repository navigation
fix: stop background-tab feed loading, and show a deleted comment's replies on a phone - #323
Merged
therealsama merged 3 commits intoNov 4, 2026
Conversation
therealsama
force-pushed
the
fix/background-feed-loading-and-phone-deleted-comments
branch
from
November 4, 2026 11:58
8998b1c to
ed54679
Compare
The list loaded the next page whenever its end-of-list marker was reported in view and nothing was loading. That report only changes when the browser's intersection observer runs, and it doesn't while the page isn't drawn. Network requests still finish, so in a background tab each page that landed turned `loading` back off and the list loaded again. In Chromium, scrolling to the bottom of the Top feed and switching tabs while the next page loaded went on to fetch 22 more pages in 40 seconds, 20 to 638 cards, with the scroll position unchanged. It stops only at the feed's 365-day limit, or the end of a domain's or user's results, or when the tab comes back. With the tab in front, one scroll to the bottom loaded two pages, as the check ran before the browser reported the marker's new position. The list now measures the marker again before each load and skips it when the marker is more than the preload margin below the viewport. A background tab loads only the page already in flight, and one scroll to the bottom loads one page. The check uses the layout viewport, which the observer measures against, through the root element's `clientHeight`. On a zoomed-in iPad, which shows this list when a trackpad or mouse is connected, `innerHeight` is only the part on screen: the check would skip a load the observer had asked for, and the list would stop loading.
The phone's full-screen comment showed "Comment deleted", with nothing else, for any comment with no author and no text, even one with replies. The desktop page shows the same comment under a [deleted] byline, with its parent and story links and its replies. Tapping "parent" on reply 50343707 on a phone led to such a dead end for comment 50343637. The phone now shows the dead end only when the comment has no replies and none are still loading. Otherwise it renders the comment as the desktop page does.
useItemWithComments read the item cache in its body, which parses the cached thread from localStorage on every render, though the result only seeds the initial state. Over five swipes on a phone-speed CPU, those reads parsed 3.3 million characters, about 18ms. It now reads the cache once, in a state initializer.
therealsama
force-pushed
the
fix/background-feed-loading-and-phone-deleted-comments
branch
from
November 4, 2026 14:17
ed54679 to
c4d2a0f
Compare
therealsama
enabled auto-merge
November 4, 2026 14:45
kplachkov
approved these changes
Nov 4, 2026
therealsama
deleted the
fix/background-feed-loading-and-phone-deleted-comments
branch
November 4, 2026 14:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two bugs and a small performance issue.
Bug fixes
loadingback off and the list loaded again. In Chromium, scrolling to the bottom of the Top feed and switching tabs while the next page loaded fetched 22 more pages in 40 seconds: 20 to 638 cards, a page 49,000px tall, the scroll position unchanged. It stopped when the tab came back. Left alone it goes on to the feed's 365-day limit, or to the end of a domain's or user's results, since those pages share the list. With the tab in front, one scroll to the bottom loaded two pages for the same reason. The list now measures the marker again before each load and skips the load when the marker is more than the 200px preload margin below the viewport. In the same test, the background tab loaded only the page already in flight. One scroll to the bottom now loads one page, and each further scroll still loads the next. The check measures against the layout viewport, the one the observer uses, through the root element'sclientHeight. On a zoomed-in iPad, which shows this list when a trackpad or mouse is connected,window.innerHeightis only the part on screen: measuring against it would skip loads the observer had asked for, and the list would stop loading.[deleted]byline, with its parent and story links and its replies. Tapping "parent" on reply 50343707 led to that dead end for 50343637. The phone now shows the dead end only when the comment has no replies and none are still loading. Otherwise it renders the comment as the desktop page does.Performance
useItemWithCommentsparsed the cached thread on every render, though the read only seeds the initial state. Over five phone swipes with the CPU slowed 4×, those reads parsed 3.3 million characters, about 18ms in total. All item-cache reads in that test went from 152 to 20. It now reads the cache once, in a state initializer.Known limitations